package com.wc.alorithm_blue_bridge._动态规划.线性DP.翻转;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/5/22 15:19
 * @description https://www.lanqiao.cn/problems/18427/learning/?problem_list_id=33&page=1
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static char[][] s = new char[N][];
    static int[][] f = new int[N][2];
    static int n;

    public static void main(String[] args) {
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            s[i] = (" " + sc.next()).toCharArray();
        }
        f[1][0] = f[1][1] = 2;
        for (int i = 2; i <= n; i++) {
            f[i][0] = Math.min(f[i - 1][0] + 2 - (s[i - 1][2] == s[i][1] ? 1 : 0),
                    f[i - 1][1] + 2 - (s[i - 1][1] == s[i][1] ? 1 : 0));

            f[i][1] = Math.min(f[i - 1][0] + 2 - (s[i - 1][2] == s[i][2] ? 1 : 0),
                    f[i - 1][1] + 2 - (s[i - 1][1] == s[i][2] ? 1 : 0));
        }
        out.println(Math.min(f[n][0], f[n][1]));
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
